<template>
	<div class="content">
		<div class="refresh" @click="refresh">版本号：{{ version }} <br> SN: {{ deviceInfo.sn }} </div>
		<div class="setting-box">
			<van-form>
				<van-field label="测试模式:">
					<template #input>
						<van-switch :value="form.isTest" @change='switchChange($event, "isTest")' />
					</template>
				</van-field>
				<!-- <van-field label="温州妇产系统核验记录上传开通:" label-width="220px">
					<template #input>
						<van-switch :value="form.permissionOpen" @change='switchChangeN($event, "permissionOpen")' />
					</template>
				</van-field> -->
				<van-button round block type="danger" @click="logout">退出程序</van-button>
				<van-button round block type="info" @click="getconfig">获取机器配置</van-button>
			</van-form>
		</div>
		<div class="back" @click="$router.go(-1)">
			《 返回
		</div>
	</div>
</template>

<script>
import VConsole from 'vconsole';
import {
	mapState,
	mapMutations,
	mapActions
} from 'vuex'
import {
	decryptByDES,
} from "@/utils/index";
import XH from '@/common/xh-ybjssdk';
export default {
	data() {
		return {
			form: {
				isTest: false,
				permissionOpen: false,
			}
		}
	},
	computed: {
		...mapState(['deviceInfo', 'desKey','system']),
		version() {
			return process.env.version
		},

	},
	mounted() {
		this.form.isTest=this.system.isTest
	},

	methods: {
		...mapMutations(['setUserInfo', 'setDeviceInfo', 'setSystem']),
    getconfig(){
      XhAggregation.getConfig({
        success: async (res)=> {
          console.log('res:getConfig', res);

        }
      })
    },
		refresh() {
			window.localStorage.clear();
			window.sessionStorage.clear();
			window.location.href = `${window.location.origin}${window.location.pathname}${window.location.search}`;
		},
		switchChange(e, type) {
			this.setSystem({
				[type]: e
			})
			this.form[type] = e;
			if (e) {
				window.vConsole = new VConsole();
			} else if (window.vConsole) {
				window.vConsole.destroy();
			}
		},
		switchChangeN(e,type){
			this.form[type] = e;
		},
		logout(){
			XhAggregation.backHome()
		},
	}
};
</script>
<style lang="less" scoped>
.content {
	background: url('@/assets/images/index/bg.png');
	background-size: 100%;
	width: 100vw;
	height: 100vh;


	.refresh {
		position: relative;
		left: 0px;
		top: 10px;
		width: 150px;
		height: 30px;
		line-height: 1.4;
		color: #fff;
		font-size: 10px;
		padding-left: 10px;
		// background: #000;
	}

	.setting-box {
		background: #fff;
		border-radius: 15px;
		padding: 20px;
		top: 20px;
		width: 340px;
		margin: 0 auto;
		position: relative;
	}
	.back{
		background: linear-gradient(to bottom, #edd35b, #eba503);
		color: #fff;
		border-radius: 10px;
		display: inline-block;
		width: 80px;
		line-height: 30px;
		font-size: 16px;
		text-align: center;
		font-weight: 600;
		position: absolute;
		top: 10px;
		right: 10px;
	}
}
</style>